﻿using UnityEngine;
using System.Collections;

public class DoorUpDown_Organ : MonoBehaviour
{
    public float MinY, MaxY;
    public float DoorSpeed;
    IEnumerator Move(float target)
    {
        float sign = Mathf.Sign(target - transform.position.y);
        while (Mathf.Abs(target - transform.position.y) > 0.06f)
        {
            transform.Translate(0, sign * DoorSpeed * Time.deltaTime, 0);
            yield return new WaitForEndOfFrame();
        }
    }
    public void MoveDown()
    {
        StopAllCoroutines();
        StartCoroutine(Move(MinY));
    }
    public void MoveUp()
    {
        StopAllCoroutines();
        StartCoroutine(Move(MaxY));
    }
}
